package com.zkingsoft.actions.admin;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.anotations.RemoveRequestToken;
import com.zkingsoft.anotations.SaveRequestToken;
import com.zkingsoft.constance.Dictionary;
import com.zkingsoft.model.FlowExperienceCoin;
import com.zkingsoft.model.Users;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.plugin.util.WebUtil;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.FlowExperienceCoinService;
import com.zkingsoft.services.UsersService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-12-01 09:57
 */
@Controller
@RequestMapping(value = "admin/flowExperienceCoin")
public class FlowExperienceCoinController extends BaseController{

	@Resource
	private FlowExperienceCoinService currentService;
	@Resource
	private UsersService userService;
	
	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(FlowExperienceCoin flowExperienceCoin, PaginationVO pageVo) {
		return showList(currentService, flowExperienceCoin, pageVo);
	}
   	
	@RemoveRequestToken	
   	@RequestMapping(value = "/addOrModify")
	public @ResponseBody AjaxResult addOrModify(FlowExperienceCoin flowExperienceCoin) {
		if (flowExperienceCoin.getId() != null) {
			return modify(currentService, flowExperienceCoin, "flowExperienceCoin");
		} else {
			return add(currentService, flowExperienceCoin, "flowExperienceCoin");
		}
	}
	
	@SaveRequestToken
   	@RequestMapping(value = "/editForm")
	public String editForm(Long id) {
		FlowExperienceCoin flowExperienceCoin;
		if (id != null) {
			flowExperienceCoin = currentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", flowExperienceCoin);
		}
		return "admin/flowExperienceCoin-form";
	}
   	
   	
 	@RequestMapping(value = "/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(currentService, keys);
	}
 	
 	/**
 	 * 财富历史总排行榜
 	 */
 	@RequestMapping(value="/historicalWealth")
 	public @ResponseBody AjaxResult historicalWealth(PaginationVO pageVo){
 		//排序方式
 		pageVo.setOrder(Dictionary.ORDER_DESC);
 		//排序字段
 		pageVo.setSort(Dictionary.SORT_AGE);
 		List<Users> userList = userService.findHistorical(pageVo);
 		return new AjaxResult(AjaxResult.STATUS_OK, null, "",userList,userList.size());
 	}
 	
 	/**
 	 * 任务达人历史总排行榜
 	 */
 	@RequestMapping(value="/historicalTask")
 	public @ResponseBody AjaxResult historicalTask(PaginationVO pageVo){
 		//排序方式
 		pageVo.setOrder(Dictionary.ORDER_DESC);
 		//排序字段
 		pageVo.setSort(Dictionary.SORT_DEPT_ID);
 		List<Users> userList = userService.findHistorical(pageVo);
 		return new AjaxResult(AjaxResult.STATUS_OK, null, "",userList,0);
 	}
 	
 	/**
 	 * 财富本周排行榜
 	 */
 	@RequestMapping(value="/weekWealth")
 	public @ResponseBody AjaxResult weekWealth(PaginationVO pageVo){
 		//排序方式
 		pageVo.setOrder(Dictionary.ORDER_DESC);
 		//排序字段
 		pageVo.setSort(Dictionary.SORT_COIN);
 		List<FlowExperienceCoin> flowExperienceCoinList = currentService.selectWeekWealth(pageVo);
 		return new AjaxResult(AjaxResult.STATUS_OK, null, "",flowExperienceCoinList,flowExperienceCoinList.size());
 	}
 	
 	/**
 	 * 任务达人周排行榜
 	 */
 	@RequestMapping(value="/weekTask")
 	public @ResponseBody AjaxResult weekTask(PaginationVO pageVo){
 		//排序方式
 		pageVo.setOrder(Dictionary.ORDER_DESC);
 		//排序字段
 		pageVo.setSort(Dictionary.SORT_EXPERIENCE);
 		List<FlowExperienceCoin> flowExperienceCoinList = currentService.selectWeekTask(pageVo);
 		return new AjaxResult(AjaxResult.STATUS_OK, null, "",flowExperienceCoinList,flowExperienceCoinList.size());
 	}
 	
}